package org.wxd.bi.api.po;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wxd.ann.ShowIndex;
import org.wxd.batis.sql.mysql.MysqlDataWrapper;
import org.wxd.batis.struct.DbColumn;
import org.wxd.batis.struct.DbTable;
import org.wxd.lang.save.ObjectBase;
import org.wxd.net.web.template.ann.HtmlStyle;
import org.wxd.str.json.Object2Json;

import java.io.Serializable;
import java.util.Map;

/**
 * @author: Troy.Chen(無心道, 15388152619)
 * @version: 2021-10-12 11:50
 **/
@DbTable(mappedSuperclass = true)
public class BasePush extends ObjectBase implements Serializable {

    private static final long serialVersionUID = 1L;
    private static final Logger log = LoggerFactory.getLogger(BasePush.class);

    @ShowIndex(value = 1)
    @HtmlStyle("width: 180px")
    @DbColumn(key = true, comment = "编号")
    protected long id;
    @ShowIndex(value = 2)
    @HtmlStyle("width: 200px")
    @DbColumn(index = true, comment = "保存时间")
    protected long saveTime;
    /**
     * 扩展信息，最多2万个字符，没有索引
     */
    @DbColumn(length = 20000, comment = "扩展信息")
    protected String expand;

    public BasePush() {
    }

    public BasePush(String expand) {
        this.expand = expand;
    }

    public long getId() {
        return id;
    }

    public BasePush setId(long id) {
        this.id = id;
        return this;
    }

    public long getSaveTime() {
        return saveTime;
    }

    public BasePush setSaveTime(long saveTime) {
        this.saveTime = saveTime;
        return this;
    }

    /**
     * 扩展信息
     *
     * @return
     */
    public String getExpand() {
        return expand;
    }

    /**
     * @param expand 扩展信息，最多2万个字符，没有索引
     * @return
     */
    public BasePush setExpand(String expand) {
        this.expand = expand;
        return this;
    }

    public String pushName() {
        return MysqlDataWrapper.Default.tableName(this);
    }

    public String pushString() {
        final Map<String, Object> stringStringMap = MysqlDataWrapper.Default.toJsonMap(this);
        return Object2Json.toJson(stringStringMap);
    }

}
